
<title>管理员密码设置</title>

<div class="layui-card layadmin-header">
  <div class="layui-breadcrumb" lay-filter="breadcrumb">
    <a lay-href="">主页</a>
    <a><cite>管理员密码设置</cite></a>
  </div>
</div>

<div class="layui-fluid">
  <div class="layui-card">
    <div class="layui-card-header">系统设置</div>
    <div class="layui-card-body" style="padding: 15px;">
      <form class="layui-form" action="" lay-filter="component-form-group">
        <script type="text/html" template lay-url="{{ layui.setter.baseUrl }}sysset/adminset" 
        lay-done="layui.form.render(null, 'component-form-group');">

          <div class="layui-form-item">
            <label class="layui-form-label">旧密码</label>
            <div class="layui-input-block">
              <input type="password" id="oldpw" name="oldpw" value="" lay-verify="required" autocomplete="on"  class="layui-input">
            </div>
          </div>
          
          <div class="layui-form-item">
            <label class="layui-form-label">新密码</label>
            <div class="layui-input-block">
              <input type="password" id="newpw" name="newpw" value="" lay-verify="required" autocomplete="on"  class="layui-input">
            </div>
          </div>
          
          <div class="layui-form-item">
            <label class="layui-form-label">确认密码</label>
            <div class="layui-input-block">
              <input type="password" id="surepw" name="surepw" value="" lay-verify="required" autocomplete="on"  class="layui-input">
            </div>
          </div>
          
          <div class="layui-form-item">
            <div class="layui-input-block">
              <div class="layui-footer">
                <input type="hidden" id="token" name="data[token]" value="{{ d.data.token }}">
                <button class="layui-btn" lay-submit="" lay-filter="component-form-demo1" name="submit">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
              </div>
            </div>
          </div>
        </script>
      </form>
    </div>
  </div>
</div>

<script>
layui.use(['admin', 'form'], function(){
    var $ = layui.$
    ,admin = layui.admin
    ,element = layui.element
    ,layer = layui.layer
    ,form = layui.form
    
    /* 监听提交 */
    form.on('submit(component-form-demo1)', function(data){
        $.post(
            layui.setter.baseUrl+'sysset/adminset',
            data.field,
            function(ret){
                var {code,msg,data} = ret;
                if(code==0){
                    $('#token').val(data.token);
                    layer.msg('提交成功！');
                    
                    location.reload();
                    
                }else{
                    layer.msg(msg);
                }
            }
        );
        return false;
    });
});
</script>